import moduleRegist from '@/utils/moduleRegist';
import {
  module as appModule
} from './module';
import Admin from './admin';
const Layout = resolve => {
  require(['./Layout'], resolve);
};

const Signin = resolve => {
  require(['./Signin'], resolve);
};

const CallBack = resolve => {
  require(['./CallBack'], resolve);
};

const Oauth2Authorize = resolve => {
  require(['./Oauth2Authorize'], resolve);
};

const WiiOauth2Authorize = resolve => {
  require(['./WiiOauth2Authorize'], resolve);
};

const AppQrCodeSignIn = resolve => {
  require(['./AppQrCodeSignIn'], resolve);
};

const ResetPassword = resolve => {
  require(['./ResetPassword'], resolve);
};

const NoPermission = resolve => {
  require(['@/components/NoPermission'], resolve);
};

const routeConfig = {
  path: '/',
  redirect: '/admin',
  component: Layout,
  meta: {
    title: '首页',
    name: '首页'
  },
  children: [{
    path: 'signin',
    component: Signin,
    meta: {
      title: '登陆',
      name: '登陆',
      icon: 'md-lock',
      noAuthc: true
    }
  }, {
    path: 'callBack',
    component: CallBack,
    meta: {
      title: '登陆',
      name: '登陆',
      icon: 'md-lock',
      noAuthc: true
    }
  }, {
    path: 'oauth2/authorization',
    component: Oauth2Authorize,
    meta: {
      title: '认证中心-登陆',
      name: '认证中心-登陆',
      icon: 'md-lock',
      noAuthc: true
    }
  }, {
    path: 'oauth2/wiiAuthorization',
    component: WiiOauth2Authorize,
    meta: {
      title: '认证中心-登陆',
      name: '认证中心-登陆',
      icon: 'md-lock',
      noAuthc: true
    }
  }, {
    path: 'appQrCodeSignIn',
    component: AppQrCodeSignIn,
    meta: {
      title: '认证中心-登陆',
      name: '认证中心-登陆',
      icon: 'md-lock',
      noAuthc: true
    }
  }, {
    path: 'resetPassword',
    component: ResetPassword,
    meta: {
      title: '重置密码',
      name: '重置密码',
      icon: 'md-lock',
      noAuthc: true
    }
  }, {
    path: '403',
    component: NoPermission,
    meta: {
      title: '403',
      name: '403',
      icon: 'md-lock'
    }
  }, ...Admin],
  beforeEnter: (to, from, next) => {
    moduleRegist(appModule);
    next();
  }
};
export default [routeConfig];
